package com.itheima_03;

import java.lang.annotation.Annotation;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Test {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        //获取带有注解的对象
        Class clazz = Class.forName("com.itheima_03.Preson");
        //获取注解
        Anno anno = (Anno) clazz.getAnnotation(Anno.class);
        String className = anno.className();
        String methodName = anno.methodName();

        //拿到两个参数,开始反射
        Class clazz1 = Class.forName(className);
        //创建对象
        Object o = clazz1.newInstance();
        Method method = clazz1.getMethod(methodName);

        method.invoke(o);


    }
}
